package chat.protocol;

import java.util.Scanner;
import java.util.regex.Pattern;

import chat.data.ChatState;
import chat.network.SocketClient;
import chat.userInterface.ChatUI;

public class ChatProtocol implements Protocol, ChatCommand{
	private ChatState state;
	private SocketClient client;
	private Scanner scanner;

	public void processInput(String message) {
		scanner = new Scanner(message);
		scanner.useDelimiter(PATTERN);
		if(scanner.next().equals(MESSAGE)){
			if(state == null){
				System.out.println(message);
			} else {
				state.message(message);
			}
		}
		scanner.close();
	}
	public void addState(ChatState s){
		state = s; 
	}
	public void addClient(SocketClient c){
		client = c;
	}
}
